using System;
using System.Collections.Generic;
using System.Text;

using RecruitmentSystem.Common;
using RecruitmentSystem.DataAccess;

namespace RecruitmentSystem.Business
{
    public class LoginManager
    {
        private UserAccessor userAccessor;

        public LoginManager()
        {
            userAccessor = new UserAccessor();
        }

        public bool Login(string username, string password, UserType userType)
        {
            bool result = false;

            try
            {
                switch (userType)
                {
                    case UserType.EnterpriseUser:
                        result = userAccessor.CheckEnterpriseUser(username, password);
                        break;
                    case UserType.SchoolUser:
                        result = userAccessor.CheckSchoolUser(username, password);
                        break;
                    case UserType.PersonalUser:
                        result = userAccessor.CheckPersonalUser(username, password);
                        break;
                    case UserType.AdminUser:
                        result = userAccessor.CheckAdminUser(username, password);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occurs in login", ex);
            }

            return result;
        }
    }
}
